<!-- 收支明细 -->
<template>
	<view>
		<u-navbar :isFixed="true" title="收支明细" :borderBottom="false"></u-navbar>
		<view class="tab flex_bet">
			<view class="item" v-for="(item,index) in typelist" :key="index" @click="tabClick(index)">
				<view class="name" :class="index==current?'current':''">{{item.name}}</view>
				<view class="line" v-show="index==current"></view>
			</view>
		</view>
		<picker @change="setdate" mode="date" fields="month">
			<view class="dateshow">{{date?date:"全部"}}</view>
		</picker>
		<view class="wrap">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="flex_bet_align">
					<view class="title">{{item.desc}}</view>
					<view class="price" :class="item.status==1?'reduce':'add'">{{item.money}}元</view>
				</view>
				<view class="flex_bet_align">
					<view class="time">{{item.createtime}}</view>
					<view class="balance">余额：{{item.original_money}}元</view>
				</view>
			</view>
		</view>
		<view class="not_more" v-if="list.length<1">
			<image src="../static/img/wxiaoxi.png" mode="widthFix"></image>
			<view class="text">暂无明细</view>
		</view>
	</view>
</template>

<script>
	var _this, $paginator;
	export default {
		data() {
			return {
				typelist:[
					{name:'支出'},
					{name:'收入'}
				],
				current:0,
				date:"",
				list:[],
			}
		},
		onLoad() {
			_this = this
			$paginator = new _this.$paginator(_this.$api)
			_this.getdata(true)
		},
		onReachBottom: function() {
			$paginator.nextPager(() => {
				_this.getdata()
			})
		},
		methods: {
			getdata: function(firstLoad = false) {
				let data={}
				data.type=parseInt(_this.current)+1
				if(_this.date){
					data.date=_this.date
				}
				$paginator.getData('walletdetailed',data, (data) => {
					if (firstLoad) {
						_this.list = data.list ? data.list : []
					} else {
						_this.list = _this.list.concat(data.list)
					}
					_this.nomore = data.nomore
				})
			},
			tabClick(e){
				this.current = e
				$paginator = new _this.$paginator(_this.$api)
				_this.getdata(true)
			},
			setdate(e){
				_this.date=e.target.value
				$paginator = new _this.$paginator(_this.$api)
				_this.getdata(true)
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	page{
		font-family: PingFang SC;
	}
	.tab{
		width:100%;
		padding: 40rpx 0 28rpx;
		.item{
			flex:1;
			text-align: center;
			.name{
				font-size: 30rpx;
				font-weight: 500;
				color: #666666;
			}
			.current{
				color:#000000 !important;
			}
			.line{
				width: 38rpx;
				height: 5rpx;
				margin:8rpx auto 0;
				background: #38be8c;
				border-radius: 3rpx;
			}
		}
	}
	.dateshow{
		padding: 0 38rpx;
		line-height: 80rpx;
		background: #f2f2f2;
	}
	.timeList{
		width: 750rpx;
		height: 71rpx;
		background: #f2f2f2;
	}
	.wrap{
		padding:0 38rpx;
		.item{
			padding:51rpx 0 44rpx;
			border-bottom: 1rpx solid #EEEEEE;
			.title{
				font-size: 28rpx;
				font-weight: 500;
				color: #000000;
				margin-bottom: 27rpx;
				margin-right: 30rpx;
				flex: 1;
			}
			.price{
				font-size: 28rpx;
				font-weight: 500;
			}
			.add{
				color: #38be8c;
			}
			.reduce{
				color:#FE1E00;
			}
			.time{
				font-size: 22rpx;
				font-weight: 500;
				color: #999999;
			}
			.balance{
				font-size: 22rpx;
				font-weight: 500;
				color: #999999;
			}
		}
	}
</style>
